home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / laptop-mode-tools / modules / video-out < prev    next >
Text File  |  2009-10-06  |  1KB  |  47 lines

  1. #! /bin/sh
  2. # Laptop mode tools module: selectively disable video outputs
  3. #
  4.  
  5. do_xrandr () {
  6.       w -hs | while read -r USER TTY DISPLAY REMAINDER; do    
  7.           if [ "${DISPLAY#:}" != "$DISPLAY" ] ; then
  8.               # It's an X display.
  9.               if su $USER -c "xrandr --output $1 --$2" 2>> $OUTPUT | grep -q display >> $OUTPUT 2>&1 ; then
  10.                 $LM_VERBOSE && echo "Unable to set video output $1 to $2." >> $OUTPUT
  11.             else 
  12.                 $LM_VERBOSE && echo "Set video output $1 to $2" >> $OUTPUT
  13.             fi
  14.         fi
  15.         done
  16. }
  17.  
  18. if [ x$CONTROL_VIDEO_OUTPUTS = x1 ] ; then
  19.     if [ $ON_AC -eq 1 ]; then
  20.         if [ "$ACTIVATE" -eq 1 ]; then
  21.             DISABLE_VIDEO_OUTPUTS="$LM_AC_THROTTLE_ETHERNET"
  22.         else
  23.             DISABLE_VIDEO_OUTPUTS="$NOLM_AC_THROTTLE_ETHERNET"
  24.         fi
  25.     else
  26.         DISABLE_VIDEO_OUTPUTS="$BATT_THROTTLE_ETHERNET"
  27.     fi
  28.  
  29.     if [ -f /var/run/laptop-mode-tools/disabled-video-outputs ] ; then
  30.         cat /var/run/laptop-mode-tools/disabled-video-outputs |
  31.             while read VIDEO_OUTPUT REMAINDER ; do
  32.                 do_xrandr $VIDEO_OUTPUT auto
  33.             done
  34.     fi
  35.             
  36.     rm -f /var/run/laptop-mode-tools/disabled-video-outputs
  37.     
  38.     for VIDEO_OUTPUT in $DISABLE_VIDEO_OUTPUTS ; do
  39.         echo $VIDEO_OUTPUT >> /var/run/laptop-mode-tools/disabled-video-outputs
  40.         
  41.         do_xrandr $VIDEO_OUTPUT off
  42.     done
  43. else
  44.     $LM_VERBOSE && echo "video-out module is disabled." >> $OUTPUT
  45. fi
  46.